package com.haiyi.activiti.engine.framework.activiti.gateway;

import org.activiti.bpmn.model.ExclusiveGateway;
import org.activiti.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior;
import org.activiti.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * <p> </p>
 *
 * <pre> Created: 2018/12/7 10:37 </pre>
 *
 * @author hlu
 * @version 1.0
 * @since JDK 1.7
 */
@Component
public class ActivityBehaviorFactoryExt extends DefaultActivityBehaviorFactory {
    @Autowired
    private ExclusiveGatewayActivityBehaviorExt exclusiveGatewayActivityBehaviorExt;
    @Autowired
    private SpringProcessEngineConfiguration springProcessEngineConfiguration;

    @Autowired
    private ProcessEngineConfigurationImpl configuration;

    @Override
    public ExclusiveGatewayActivityBehavior createExclusiveGatewayActivityBehavior(ExclusiveGateway exclusiveGateway) {
        return exclusiveGatewayActivityBehaviorExt;
    }

    @PostConstruct
    public void init(){
        configuration.getBpmnParser().setActivityBehaviorFactory(this);
        springProcessEngineConfiguration.setActivityBehaviorFactory(this);
    }
}
